function gotoaddProduct(dom,cateId,cateTitle,posId,addproduct){
	if($("#count"+posId).html()=="0"||$("[countcategory]").attr("countcategory")=="0"){
		simpleDialog("Category Empty");
	}else{
		if(cateId == "")
			cateId = "0";
		var dataForAdd = {cateId:cateId,posId:posId,addproduct:addproduct};
		if(cateTitle!=""&&cateTitle!=undefined){
			currentSubPage.cateTitle = cateTitle;
		}
		var dialog = editAdminDataDialog("left",dom,label_addProduct,"/adminconsole/POSManager/POSProduct/AddPOSProduct.jsp","addDialogProduct",AddEventClickProduct,loadTaxElementFinishProduct,dataForAdd);
	}
}

function loadTaxElementFinishProduct(dialog,dataForAdd){
	dialog.parents(".ui-dialog:first").css("width",600);
	setOptionPosProduct(dataForAdd);
}
function setOptionPosProduct(dataForAdd){
	if(dataForAdd.posId!=""&&dataForAdd.posId!=undefined&&dataForAdd.cateId!=""&&dataForAdd.cateId!=undefined&&dataForAdd!=""&&dataForAdd!=undefined){
		var url = "/POSItemService";
		var data = { func : "getOption",posId : dataForAdd.posId,cateId : dataForAdd.cateId}
		simpleserviceWithArgs(url,data,setSuccessProduct,dataForAdd);
	}else if(dataForAdd.cateId==0){
		var url = "/POSItemService";
		var data = { func : "getOption",posId : dataForAdd.posId,cateId : dataForAdd.cateId}
		simpleserviceWithArgs(url,data,setSuccessProduct,dataForAdd);
	}else{
		var posId = "";
		if(dataForAdd.posId!="")
			posId = dataForAdd.posId
		else
			posId = $("[name=pospointproduct]").val();
		var url = "/POSItemService";
		var data = { func : "getOption",
				posId : posId
		}
		simpleserviceWithArgs(url,data,setSuccessProduct,dataForAdd);
	}
}
function setSuccessProduct(data,dataForAdd){
	var objArray = new Array();
	objArray = JSON.parse(data);
	//$("[name=cateId]").val(dataForAdd.cateId);
	$("[name=pospointproduct] option").remove();
	$("[name=categoryproduct] option").remove();
	$("[name=unitproduct] option").remove();
	for (key in objArray[0].pospoint)$("[name=pospointproduct]").append('<option value="' + objArray[0].pospoint[key].id + '">' + objArray[0].pospoint[key].Title + '</option>');
	if(objArray[0].category.length!=0){
		for (key in objArray[0].category){
			var parent = "";
			for(var i =0;i<objArray[0].category[key].countparentCategory;i++){
				parent += "->"
			}
			$("[name=categoryproduct]").append('<option value="' + objArray[0].category[key].id + '">' +parent+ objArray[0].category[key].title + '</option>');
		}
	}/*else{
		$("[id*=BlankDialog]:visible").remove();
		var buttons = [{ title:"OK" , callback: function(thisdialog,args){}}];
		var dialog = customDialog("test","<table style='width:50px;'><tr><td>Category Empty</td></tr></table>",null,buttons,null);
		dialog.find(".ui-newdialog-content").css("width",50);
	}*/
	$("[name=categoryproduct]").attr("onchange","setOptionPosProduct({posId:"+dataForAdd.posId+",cateId:this.value})")
	for (key in objArray[0].unit)$("[name=unitproduct]").append('<option value="' + objArray[0].unit[key].id + '">' + objArray[0].unit[key].title + '</option>');
	if(dataForAdd.posId!=undefined&&dataForAdd!=""){
		$("[name=pospointproduct] option[value=" + dataForAdd.posId +"]").attr("selected","selected");
		if(objArray[0].category.length!=0){
			$("[name=categoryproduct] option[value=" + dataForAdd.cateId +"]").attr("selected","selected");
		}
		$("[name=unitproduct] option[value=" + dataForAdd.unitId +"]").attr("selected","selected");
	}else{
		$("[name=pospointproduct] option[value=" + dataForAdd +"]").attr("selected","selected");
	}
	var textTax = "";
	for(var i=0;i<objArray[0].taxcate.length;i++){
		var symbolSet = "";
		if(objArray[0].taxcate[i].isPercent==true)
			symbolSet = "%";
		else
			symbolSet = symbol;
		textTax += "<span><input type='checkbox' ispercent="+objArray[0].taxcate[i].isPercent+" value="+objArray[0].taxcate[i].currencyValue+" id="+objArray[0].taxcate[i].taxId+" name='checktax'> "+
		objArray[0].taxcate[i].taxTitle+"("+objArray[0].taxcate[i].currencyValue+" "+symbolSet+")</span><br>";
	}
	if(textTax!=""){
		$("[name=taxproduct]:visible").replaceWith('<tr name="taxproduct"><td  style="width:22%;text-align:right;">'+taxDialog+'</td><td>'+textTax+'</td><tr>');	
	}else{
		$("[name=taxproduct]:visible").replaceWith('<tr name="taxproduct"></tr>');
	}
}

function AddEventClickProduct(dialog,dataForAdd){
	var pospoint = dialog.find("[name=pospointproduct]").val();
	var title = dialog.find("#title").val();
	var idproduct = dialog.find("[name=idproduct]").val();
	var favourite = dialog.find("[name=favourite]").is(":checked");
	var categoryproduct = dialog.find("[name=categoryproduct]").val();
	if(dataForAdd.addproduct==null){
		dataForAdd = {cateId:dataForAdd.cateId,posId:dataForAdd.posId,addproduct:'addproduct',categoryproduct:categoryproduct};
	}else{
		dataForAdd = {cateId:dataForAdd.cateId,posId:dataForAdd.posId,addproduct:dataForAdd.addproduct,categoryproduct:categoryproduct};
	}
	var priceproduct = dialog.find("[name=priceproduct]").val();
	var unitproduct = dialog.find("[name=unitproduct]").val();
	var value=0;
	for(var i =0;i<dialog.find("[name=checktax]").size();i++){
		if($(dialog.find("[name=checktax]")[i]).is(":checked")==true){
			if($(dialog.find("[name=checktax]")[i]).attr("ispercent") == "false"){
				value  += parseInt($(dialog.find("[name=checktax]")[i]).attr("value"));
			}
		}
	}
	var taxuse = "";
	for(var i =0;i<dialog.find("[name=checktax]").size();i++){
		if($(dialog.find("[name=checktax]")[i]).is(":checked")==true){
			taxuse +=  $(dialog.find("[name=checktax]")[i]).attr("id")+",";
		}
	}
	if(isIncludetax=="false"){
		if(parseInt(priceproduct)>value){
			taxuse = taxuse.substring(0, taxuse.length-1);
			var des = dialog.find("#description").val();
			var url = "/POSItemService";
			var func = "addPOSItem";
			var data = { func:func,
					pospoint:pospoint,
					title:title,
					idproduct:idproduct,
					favourite:favourite,
					categoryproduct:categoryproduct,
					priceproduct:priceproduct,
					unitproduct:unitproduct,
					taxuse:taxuse,
					cateId:categoryproduct,
					description : des
				}
			simpleserviceWithArgs(url,data,showPOSProduct,dataForAdd);
		}else{
			simpleDialog("<span style='text-align:center'>Error Price</span>");
		}
	}else{
		taxuse = taxuse.substring(0, taxuse.length-1);
		var des = dialog.find("#description").val();
		var url = "/POSItemService";
		var func = "addPOSItem";
		var data = { func:func,
				pospoint:pospoint,
				title:title,
				idproduct:idproduct,
				favourite:favourite,
				categoryproduct:categoryproduct,
				priceproduct:priceproduct,
				unitproduct:unitproduct,
				taxuse:taxuse,
				cateId:categoryproduct,
				description : des
			}
		simpleserviceWithArgs(url,data,showPOSProduct,dataForAdd);
	}
}

function EditPOSProduct(dom,id,cateId,posId,unitId){
	var dataForAdd = {id:id,cateId:cateId,posId:posId,unitId:unitId};
	var dialog = editAdminDataDialog("right",dom,label_add,"/adminconsole/POSManager/POSProduct/AddPOSProduct.jsp","addDialog",EditEventClick,loadEditElementFinishProduct,dataForAdd);
}

function loadEditElementFinishProduct(dialog,dataForAdd){
	cursorDialogResize(dialog,{width:600});
	setOptionPosProduct(dataForAdd);
	
	EditProduct(dataForAdd.id,dialog);
}

function EditEventClick(dialog,id){
	var pospoint = dialog.find("[name=pospointproduct]").val();
	var title = dialog.find("#title").val();
	var idproduct = dialog.find("[name=idproduct]").val();
	var favourite = dialog.find("[name=favourite]").is(":checked");
	var categoryproduct = dialog.find("[name=categoryproduct]").val();
	var priceproduct = dialog.find("[name=priceproduct]").val();
	var unitproduct = dialog.find("[name=unitproduct]").val();
	var taxuse = "";
	for(var i =0;i<dialog.find("[name=checktax]").size();i++){
		if($(dialog.find("[name=checktax]")[i]).is(":checked")==true){
			taxuse +=  $(dialog.find("[name=checktax]")[i]).attr("id")+",";
		}
	}
	taxuse = taxuse.substring(0, taxuse.length-1);
	var des = dialog.find("#description").val();
	var url = "/POSItemService";
	var func = "editPOSItem";
	var data = { func:func,
			id:id.id,
			pospoint:pospoint,
			title:title,
			idproduct:idproduct,
			favourite:favourite,
			categoryproduct:categoryproduct,
			priceproduct:priceproduct,
			unitproduct:unitproduct,
			taxuse:taxuse,
			cateId:categoryproduct,
			description : des
		}
	simpleserviceWithArgs(url,data,showPOSProduct,id.cateId);
}

function EditProduct(id,dialog){
	if(id != null){
		var url = "/POSItemService";
		var data = { func : "getPOSItemById",
				id : id
			}
		simpleserviceWithArgs(url,data,editSuccessProduct,dialog);
	}
}

function editSuccessProduct(data,dialog){
	var objArray = new Array();
	objArray = JSON.parse(data);
	dialog.find("#title").val(objArray['title']);
	dialog.find("[name=idproduct]").val(objArray['productId']);
	if(objArray['favourite']>0)
		dialog.find("[name=favourite]").attr('checked', true);
	dialog.find("[name=categoryproduct]").val(objArray['categoryString']);
	dialog.find("[name=priceproduct]").val(objArray['price']);
	var textTax = "";
	var textAllTax = "";
	for(var i =0;i<objArray.taxobj.length;i++){
		var isPercent = "";
		if(objArray.taxAllObj[i].isPercent==true){
			isPercent = "%";
		}else{
			isPercent = toCurrencyString(currencyStringToNumber("")).substring(0, toCurrencyString(currencyStringToNumber("")).length-4);
		}
		textTax += "<td><span><input type='checkbox' id="+objArray.taxobj[i].taxId+" name='checktax' checked='checked'> "+objArray.taxobj[i].taxTitle+"("+objArray.taxobj[i].currencyValue+" "+isPercent+" )</span></td>";
	}
	for(var i =0;i<objArray.taxAllObj.length;i++){
		if(objArray.taxAllObj[i].isPercent==true){
			isPercent = "%";
		}else{
			isPercent = toCurrencyString(currencyStringToNumber("")).substring(0, toCurrencyString(currencyStringToNumber("")).length-4);
		}
		textAllTax += "<span><input type='checkbox' id="+objArray.taxAllObj[i].taxId+" name='checktax'> "+objArray.taxAllObj[i].taxTitle+"("+objArray.taxAllObj[i].currencyValue+" "+isPercent+" )</span><br>";
	}
	if(textTax!=""){
		dialog.find("[name=taxproduct]").replaceWith('<tr><td  style="width:22%;text-align:right;">'+taxDialog+'</td>'+textTax+'<tr>');	
	}else{
		dialog.find("[name=taxproduct]").replaceWith('<tr><td  style="width:22%;text-align:right;">'+taxDialog+'</td><td>'+textAllTax+'</td><tr>');	
	}
	dialog.find("#description").val(objArray['description']);
	dialog.find("#cateId").val(objArray['categoryString']);
}

function setFilterPOSPoint(posId,cateId){
	var dataSet = {posId:posId,cateId:cateId};
	var url = "/POSService";
	var data = { func : "getFilterPOS"}
	simpleserviceWithArgs(url,data,filterPOSSucces,dataSet);
}

function filterPOSSucces(data,dataSet){
	objArray = JSON.parse(data);
	$("#pospoint option").remove();
	$("#pospoint").append('<option value="0">- All POS Points -</option>');
	for (key in objArray)$("#pospoint").append('<option value="' + objArray[key].id + '">' + objArray[key].Title + '</option>');
	$("#pospoint option[value=" + dataSet.posId +"]").attr("selected","selected");
	setFilterCategory(dataSet);
}

function setFilterCategory(dataSet){
	var url = "/POSCategoriesService";
	var data = { func : "getFilterCategory",
				 posId:dataSet.posId
				}
	simpleserviceWithArgs(url,data,filterCategorySucces,dataSet);
}

function filterCategorySucces(data,dataSet){
	objArray = JSON.parse(data);
	$("#categoryId option").remove();
	$("#categoryId").append('<option value="0">- All POS Points -</option>');
	for (key in objArray){
		var parent = "";
		for(var i =0;i<objArray[key].countparentCategory;i++){
			parent += "->"
		}
		$("#categoryId ").append('<option value="' + objArray[key].id + '">' +parent+ objArray[key].title + '</option>');
	}
	if(dataSet.cateId=="")
		dataSet.cateId = 0;
	$("#categoryId option[value=" + dataSet.cateId +"]").attr("selected","selected");
}
var checkPosId = "";
function showPOSProduct(data,cateId,cateTitle,subCateTitle,subCateId,id,posId,countcategory){
	var objArray = new Array();
	if(data!=null&&data!="")
		objArray = JSON.parse(data);
	var checkLogOut = checkSessionAdmin(objArray);
	if(checkLogOut)
		return;
	if(cateId!=undefined){
		if(cateId.cateId!=undefined){
			var addproduct = cateId.addproduct;
			var foraddProduct = cateId.posId;
			if(cateId.cateId=="0")
				cateId = cateId.categoryproduct;
			else
				cateId = cateId.cateId;
		}
	}
	if($($("[name=filterPOS]")[0]).css("display")=="none");
		$("[name=filterPOS]").css("display","block");
	if($("#categoryId").val()!=null&&(cateId==undefined||cateId=="")){
		cateId	= $("#categoryId").val();
	}
	if(data==undefined&&cateTitle==undefined&&subCateTitle==undefined&&subCateId==undefined&&id==undefined){
		cateId	= $("#categoryId").val();
	    subCateTitle	= $("#pospoint").val();
	    data = "";
		cateTitle = $("#categoryId").val();
	}
	if(subCateTitle==""||subCateTitle==undefined)subCateTitle	= $("#pospoint").val();
	var posId = subCateTitle;
	if(checkPosId==""||checkPosId==null||(subCateTitle!=checkPosId)){
		if(subCateTitle!=checkPosId&&checkPosId!=""){
			//cateId = 0;
		}
		checkPosId = posId;
	}
	if(checkPosId!=posId){
		cateId = 0;
	}
	if(posId==null)
		posId = JSON.parse(data).posId;
	setFilterPOSPoint(posId,cateId);
	if(cateTitle!=""&&cateTitle!=undefined){
		currentSubPage.cateTitle = cateTitle;
	}
	if($("#titleName").html()!=undefined&&$("#subTitle").html()!=undefined&&$("#titlePOS").html()!=undefined){//3 link
		if(subCateTitle==undefined||subCateTitle==null)
			subCateTitle = foraddProduct;
		var addProductOnclick = "";
		if(cateId!="")
			addProductOnclick = "gotoaddProduct($(this),"+cateId+",'',"+subCateTitle+")";
		else
			addProductOnclick = "gotoaddProduct($(this),'','',"+subCateTitle+")";
		titlePos = "<span class='link' id='titlePOS' category="+currentSubPage.pointPosId+" id='titlePOS' onclick=\""+$("#titlePOS").attr("onclick")+"\" >"
		+currentSubPage.pointPos+"</span>/";
		titleforsubProduct = "<span class='link' category="+cateId+" posId="+subCateTitle+" id='subTitle' onclick=\""+$("#subTitle").attr("onclick")+"\" >"+$("#subTitle").html()+"</span>/";
		var titleName = $("#titleName").html();
		if(subCateId==undefined)
			subCateId = $("#titleName").attr("category");
		productSubInSub =  "<span class='link' id='titleName' category="+subCateId+" posid="
		+subCateTitle+" onclick=\"showPOSCategory('','',this,"+subCateId+","+subCateTitle+",'back2')\" >"+titleName+"</span>/";
	}else{//2 link
		var titleforsubProduct = "";
		if(currentSubPage.titleForSubProduct!=undefined&&currentSubPage.idForSubProduct!=undefined&&currentSubPage.idPosForSubProduct!=undefined&&
			currentSubPage.titleForSubProduct!=""&&currentSubPage.idForSubProduct!=""&&currentSubPage.idPosForSubProduct!=""){
			var titleBack = currentSubPage.titleForSubProduct;
			var idBack    = currentSubPage.idForSubProduct;
			var idPosBack = currentSubPage.idPosForSubProduct;
			titleforsubProduct = "<span class='link' category="+idBack+" posId="+idPosBack+" onclick=\"showPOSCategory('','',this,"
			+idBack+","+idPosBack+",'back')\" >"+titleBack+"</span>/";
		}else{
			titleforsubProduct = "";
		}
		if(currentSubPage.pointPos!=undefined)
			titlePos = "<span class='link' id='titlePOS' category="+currentSubPage.pointPosId+" onclick=\"showPOSCategory('','',this,'',"
			+currentSubPage.pointPosId+",undefined,undefined,'main')\" >"+currentSubPage.pointPos+"</span>/";
		else
			titlePos= "";
		var addProductOnclick = "";
		if(cateId!="")
			addProductOnclick = "gotoaddProduct($(this),"+cateId+",'',"+subCateTitle+")";
		else
			addProductOnclick = "gotoaddProduct($(this),'','',"+subCateTitle+")";
		var productSubInSub = "";
		if($("#titlePOS").html()!=null&&$("#subTitle").html()!=null&&$("#titlePOS").html()!=null){
			var titleSub = $("#titlePOS").html();
			productSubInSub =  "<span class='link' category="+cateId+" posid="+idPosBack+" onclick=\"showPOSCategory('','',this,"
			+cateId+","+idPosBack+",'back2')\" >"+titleSub+"</span>/";
		}else
			productSubInSub = "";
	}
	
	$("#titleLinkPOSCategory").replaceWith("<div class='breadcrumb' id='titleLinkPOSCategory' countcategory="+countcategory+" >" +
			"<a href='/adminconsole/POSManager/PointPos/PointPos.jsp'><span class='link'>"+titlePoint+"</span></a>/"+
			titlePos+titleforsubProduct+productSubInSub+titleProduct+"</div>");
	$("#suggestCategory").replaceWith("<div class='destitle' id='suggestCategory'>"+suggestProduct+"</div>");
	$("#listCategory").replaceWith("<div class='titlelist' id='listCategory'>"+listProduct+"<span id='listsize'></span></div>");
	$("#addCategory").replaceWith("<span id='addCategory'><input class='addbtn' name='addtaxes' value=\""+addProduct+"\" type='button' onClick="
			+addProductOnclick+" ></span>");
	$("#delCategory").replaceWith("<span style='padding-left:10px' id='delCategory'><input class='deletebtn' name='deletetaxes' value=\""
			+delProduct+"\" type='button' onClick='deletePOSProduct()'></span>");
	// set Page
	if(id == null||id ==""||id==undefined){
		if($("[name=maxEntries]").val() == null){
			var line = 10;
		}else{
			var line = $("[name=maxEntries]").val();
		}
		if($("[name=selectpage]").val() == null){
			var pagePointer = 1; 
		}else if(cateId!=""&&(cateTitle!=""||addproduct=="addproduct")){
			var pagePointer = 1; 
		}else{
			var pagePointer = $("[name=selectpage]").val(); 
		}
	}else if(id == "next"){
		var line = $("[name=maxEntries]").val();
		var pagePointer = parseInt($("[name=selectpage]").val())+1;
	}else if(id == "previous"){
		var line = $("[name=maxEntries]").val();
		if($("[name=selectpage]").val()==null)
			var pagePointer = 1;
		else
			var pagePointer = parseInt($("[name=selectpage]").val())-1;
	}
	if(cateId=="")
		cateId = 0;
	var link = "/POSItemService";
	var data = { func: "getAllPOSItem",
				offset: (line*pagePointer)-line,
				line: line,
				pagePointer: pagePointer,
				cateId:cateId,
				posId:posId
					}
	simpleserviceWithArgs(link,data,showPOSProductList,cateId);
}

function showPOSProductList(data,cateId){
	$("[id=showList]").load("/adminconsole/POSManager/POSProduct/POSProduct.jsp",function(responseText, textStatus, XMLHttpRequest) {
		$("#showList").replaceWith(responseText);
		var objArray2 = new Array();
		objArray2 = JSON.parse(data);
		var sumtext = "";
		var text = "";
		var pageAmount = Math.ceil(objArray2[0]/objArray2[2]);
		var line = objArray2[2];
		var pagePointer = objArray2[1];
		var objArray = objArray2[3];
		$("#listsize").html("("+objArray2[0]+")");
		var lineNumber = (line * pagePointer) - (line-1);
		var description = "";
		
		if(objArray!=""&&objArray!=null&&cateId!=0){
			var categoryId = objArray[0].categoryString;
		}else{
			var categoryId = cateId;
		}
		var kitchen = "";
		var favourite = "";
		for(var i = 0;i< objArray.length+1;i++){
				if(objArray[i]!=undefined){
					if(objArray[i].description!=undefined){
						description = objArray[i]['description'];
					}else{
						description = "";
					}
					if(objArray[i].kitchenTitle!="")
						kitchen = objArray[i].kitchenTitle;
					else
						kitchen = "";
					if(objArray[i].favourite>0)
						favourite = "<span style='color:red;'>*</span>";
					else
						favourite = "";
				}
				if(i != objArray.length ){
					text = "<tr id=\"row_"+objArray[i]['id']+"\" style=\"border: 0px;\"> " +
							"<td id=\"col_1\" align=\"center\"> "+(lineNumber+i)+". </td>"+
							"<td><input type=\"checkbox\" id=\"id_"+i+"\" name=\"ids[]\" cateId= "+objArray[i].categoryString+" value=\""+objArray[i]['id']+"\"> </td>"+
							"<td align=\"left\"> "+objArray[i]['productId']+" </td>"+
							"<td align=\"left\">"+favourite+objArray[i]['title']+" </td>"+
							"<td align=\"center\">"+toCurrencyString(objArray[i]['price'])+"/"+objArray[i].unitTitle+" </td>"+
							"<td align=\"center\">"+objArray[i]['categoryTitle']+" </td>"+
							"<td align=\"center\">"+objArray[i].posTitle+" </td>"+
							"<td align=\"center\">"+kitchen+" </td>"+
							"<td align=\"center\"><a href=\"#\" onclick=\"EditPOSProduct($(this),"+objArray[i]['id']+","+objArray[i].categoryString+","+objArray[i].posId+","+objArray[i].unitString+")\">Edit</a></td>"+
							"<td align=\"center\"><a href=\"#\" onclick=\"changeStatusItem("+objArray[i]['id']+") \"> " +
							"<span id =status"+objArray[i]['id']+">"+objArray[i]['status']+"</a>" +
							"</td>" +
							"</tr>";
					sumtext += text;
				}else{
					text = "<tr>"+
					"<td colspan=\"13\" style=\"padding:0;\">"+
					"<table class=\"tablefoot\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" +
					"<tbody>"+
						"<tr>"+
							"<td width=\"33%\" align=\"left\">"+foor_page+"&nbsp;"+
								"<select name=\"selectpage\" onchange=\"showPOSProduct()\">"+
								"</select>&nbsp;"+foor_of+"&nbsp;<span id=\"pageAmount\">1</span>"+
							"</td>"+
							"<td width=\"31%\" align=\"center\">"+foor_view+
								"<select name=\"maxEntries\" onchange=\"showPOSProduct()\">"+
									"<option style=\"color:#000000\"  value=\"10\">10</option>"+
									"<option style=\"color:#000000\"  value=\"20\">20</option>"+
									"<option style=\"color:#000000\"  value=\"50\">50</option>"+
									"<option style=\"color:#000000\"  value=\"100\">100</option>"+
									"<option style=\"color:#000000\"  value=\"100000\">All</option>"+
								"</select>"+foor_rpp+" </td>" +
								"<td width=\"36%\" align=\"right\"><span id=\"previous\">&lt;&lt;"+foor_pre+"</span> |" +
								" <span id=\"next\">"+foor_next+"&gt;&gt;</span></td></tr>"+
								"</tbody></table></td></tr>";
					sumtext += text;
				}
		}
		$("#showList tr").not($("#showList tr").first()).remove();
		$("#showList").append(sumtext);
		$("#pageAmount").text(pageAmount);
		if(pagePointer+1 <= pageAmount){
			$("#next").attr("onclick","showPOSProduct('',\""+categoryId+"\",'','','',id)");
			$("#next").html("<a href=\"#\">Next&gt;&gt;</a>");
		}
		if(pagePointer > 1){
			$("#previous").attr("onclick","showPOSProduct('',\""+categoryId+"\",'','','',id)");
			$("#previous").html("<a href=\"#\">&lt;&lt;Previous</a>");
		}
		$("[name=maxEntries]").val(line);
		for ( var i = 0; i < pageAmount; i++) {
			$("[name=selectpage]").append(
					$("<option>").val((i+1)).html((i+1)));
			}
		$("[name=selectpage]").val(pagePointer);
		closeWaitingDialog();
	});
}

function changeStatusItem(id){
	waitingDialog({});
	var url = "/POSItemService";
	var data = { func : "editStatusPOSItemById",
			itemId : id
		}
	simpleservice(url,data,changeStatusSuccess);
}

function changeStatusSuccess(data){
	var objArray = new Array();
	objArray = JSON.parse(data);
	var checkLogOut = checkSessionAdmin(objArray);
	if(checkLogOut)
		return;
	$("#status"+objArray["id"]).text(objArray["status"]);
	if($("#loadingScreen").is(":visible")) closeWaitingDialog();
}

function deletePOSProduct(){
	waitingDialog({});
	var listCheckBox = "";
	var cateId = "";
	for(var i = 0;i<$('tr [type=checkbox]').not($('tr [type=checkbox]').first()).length;i++){
		if($('tr [type=checkbox]').not($('tr [type=checkbox]').first())[i].checked == true){	
			listCheckBox += $($('tr [type=checkbox]').not($('tr [type=checkbox]').first())[i]).attr("value")+",";
			cateId = $($('tr [type=checkbox]').not($('tr [type=checkbox]').first())[i]).attr("cateId");
		}
	}
	var url = "/POSItemService";
	var data = { func : "delPOSItem",
			itemId : listCheckBox.substring(0,listCheckBox.length - 1)
		}
	simpleserviceWithArgs(url,data,showPOSProduct,cateId);
}

function toggleSelect(){
	if($("#showList tr [type=checkbox]")[0].checked == true){
		for(var i = 0;i< $("#showList tr [type=checkbox]").size();i++){
			$("#showList tr [type=checkbox]")[i].checked = true;
		}
	}else{
		for(var i = 0;i< $("#showList tr [type=checkbox]").size();i++){
			$("#showList tr [type=checkbox]")[i].checked = false;
		}
	}
}